home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS1.ZIP
/
UUCP
/
UUSTAT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-02
|
38KB
|
1,091 lines
/*--------------------------------------------------------------------*/
/* u u s t a t . c */
/* */
/* Job status report for UUPC/extended */
/* */
/* */
/* Copyright 1988 (C), Dewey Coffman */
/* Changes Copyright 1991 (C), Andrew H. Derbyshire */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <stdlib.h>
/*--------------------------------------------------------------------*/
/* Local include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "dater.h"
#include "export.h"
#include "getopt.h"
#include "getseq.h"
#include "hlib.h"
#include "hostable.h"
#include "hostatus.h"
#include "import.h"
#include "pushpop.h"
#include "readnext.h"
#include "security.h"
#include "stater.h"
#include "timestmp.h"
#define DAY (60l * 60l * 24l)
#define ALL "all"
#define MAXL 128 // MAX LINE LENGTH
#define STRCREAT(s, s2, s3)\
strcpy(s, s2);\
strcat(s, s3);\
/*--------------------------------------------------------------------*/
/* Local data types */
/*--------------------------------------------------------------------*/
typedef enum {
POLL_CALL = 'P',
RECEIVE_CALL = 'R',
SEND_CALL = 'S'
} CALLTYPE;
struct data_queue {
char name[FILENAME_MAX];
struct data_queue *next_link;
time_t created;
long size;
boolean execute;
char type;
} ;
/*--------------------------------------------------------------------*/
/* Verb list */
/*--------------------------------------------------------------------*/
typedef enum {
LIST_DEFAULT = 1,
LIST_ALL,
LIST_ACCESS,
LIST_QUEUE,
KILL_JOB,
REFRESH_JOB,
FORCE_POLL
} COMMAND_CLASS;
/*--------------------------------------------------------------------*/
/* Processing to be taken by open_call */
/*--------------------------------------------------------------------*/
typedef enum {
JOB_STATUS = 1,
JOB_KILL,
JOB_REFRESH
} CALL_ACTION;
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
currentfile();
static const char *host_status[] = {
"(invalid - entry not properly initialized)",
"(local host system)",
"(host for gateway purposes only)",
"Never called",
"Dialing now",
"Invalid device or speed in SYSTEMS file",
"Device not available",
"Conversation start-up failed",
"Talking",
"Callback required",
"Modem initialization script failed",
"Dial failed",
"Script failed",
"Max retry reached",
"Retry time not reached",
"Call succeeded",
"Wrong machine name",
"Unknown host",
"Failed",
"Wrong time to call",
"(call successed, entry not reset)",
} ;
/*--------------------------------------------------------------------*/
/* Internal prototypes */
/*--------------------------------------------------------------------*/
static void all( const char *system, const char *userid );
static char *is_job(const char *jobid );
static void kill_job(const char *s);
static void long_stats( const char *system );
static void short_stats( const char *system );
static CALLTYPE open_call( const char *callname,
const char *remote,
struct data_queue **current,
char *user,
char *sys,
const CALL_ACTION action);
static void open_data(const char *file,
char *user,
char *sys,
char *command);
static void poll(const char *callee);
static void print_all( char *job,
struct data_queue *current,
const char *user,
const char *sys);
static void refresh_job(const char *s);
static void touch( const char *fname );
static void usage( void );
/*--------------------------------------------------------------------*/
/* m a i n */
/* */
/* main program */
/*--------------------------------------------------------------------*/
void main(int argc, char **argv)
{
int c;
extern char *optarg;
extern int optind;
COMMAND_CLASS command = LIST_DEFAULT;
char *system = NULL;
char *userid = NULL;
char *job = NULL;
/*--------------------------------------------------------------------*/
/* Report our version number and date/time compiled */
/*--------------------------------------------------------------------*/
debuglevel = 0;
banner( argv );
#if defined(__CORE__)
copywrong = strdup(copyright);
checkref(copywrong);
#endif
if (!configure( B_UUSTAT ))
exit(1); /* system configuration failed */
/*--------------------------------------------------------------------*/
/* Switch to the spool directory */
/*--------------------------------------------------------------------*/
tzset(); // Set up time zone information
PushDir( E_spooldir );
atexit( PopDir );
/*--------------------------------------------------------------------*/
/* Process our arguments */
/*--------------------------------------------------------------------*/
while ((c = getopt(argc, argv, "amqk:r:s:u:x:P:")) != EOF)
switch(c) {
case 'a':
command = LIST_ALL;
break;
case 'm':
command = LIST_ACCESS;
system = optarg;
break;
case 'q':
command = LIST_QUEUE;
break;
case 'k':
command = KILL_JOB;
job = optarg;
break;
case 'r':
command = REFRESH_JOB;
job = optarg;
break;
case 's':
if ( system != NULL )
{
printmsg(0,"Invalid or duplicate option -s %s",optarg);
usage();
}
system = optarg;
break;
case 'u':
userid = optarg;
break;
case 'x':
debuglevel = atoi( optarg );
break;
case 'P':
command = FORCE_POLL;
if ( system != NULL )
{
printmsg(0,"Invalid or duplicate option -P %s",optarg);
usage();
}
system = optarg;
break;
case '?':
usage();
}
if (optind != argc) {
puts("Extra parameter(s) at end.");
exit(2);
}
/*--------------------------------------------------------------------*/
/* Determine if we have a valid host */
/*-----------------------------------------